package com.ruoyi.gams.controller;

import java.util.List;

import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gams.domain.GamsWindowText;
import com.ruoyi.gams.service.IGamsWindowTextService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 窗口内容Controller
 *
 * @author ruoyi
 * @date 2021-09-03
 */
@Api(tags = "控制卡文字管理")
@RestController
@RequestMapping("/gams/window_text")
public class GamsWindowTextController extends BaseController
{
    @Autowired
    private IGamsWindowTextService gamsWindowTextService;

    /**
     * 查询窗口内容列表
     */
    @PreAuthorize("@ss.hasPermi('gams:window_text:list')")
    @GetMapping("/list")
    public TableDataInfo list(GamsWindowText gamsWindowText)
    {
        startPage();
        List<GamsWindowText> list = gamsWindowTextService.selectGamsWindowTextList(gamsWindowText);
        return getDataTable(list);
    }

    /**
     * 导出窗口内容列表
     */
    @PreAuthorize("@ss.hasPermi('gams:window_text:export')")
    @Log(title = "窗口内容", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GamsWindowText gamsWindowText)
    {
        List<GamsWindowText> list = gamsWindowTextService.selectGamsWindowTextList(gamsWindowText);
        ExcelUtil<GamsWindowText> util = new ExcelUtil<GamsWindowText>(GamsWindowText.class);
        return util.exportExcel(list, "窗口内容数据");
    }

    /**
     * 获取窗口内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('gams:window_text:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(gamsWindowTextService.selectGamsWindowTextById(id));
    }

    /**
     * 新增窗口内容
     */
    @PreAuthorize("@ss.hasPermi('gams:window_text:add')")
    @Log(title = "窗口内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GamsWindowText gamsWindowText)
    {
        return toAjax(gamsWindowTextService.insertGamsWindowText(gamsWindowText));
    }

    /**
     * 修改窗口内容
     */
    @PreAuthorize("@ss.hasPermi('gams:window_text:edit')")
    @Log(title = "窗口内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GamsWindowText gamsWindowText)
    {
        return toAjax(gamsWindowTextService.updateGamsWindowText(gamsWindowText));
    }

    /**
     * 删除窗口内容
     */
    @PreAuthorize("@ss.hasPermi('gams:window_text:remove')")
    @Log(title = "窗口内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(gamsWindowTextService.deleteGamsWindowTextByIds(ids));
    }
}
